<template>
	<view class="mainpadding2">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="margin_top xiahuaxian" v-for="item in list.data" :key="item.id">
			<view class="flexbetween ">
				<view class="flexleft">
					<view class="touxiang margin_right2">
						<image :src="item.user.avatar_text" mode=""></image>
					</view>
					<view class="">
						<view class="titletext fonweight xiaohei">{{item.user.nickname}}</view>
						<view class="strongtext nofonweight xiaohui">{{item.createtime_text}}</view>
					</view>
				</view>
				<view class="flexright">
					<u-icon name="star-fill" color="#F8B900" size="22" v-for="ite in item.score" :key="ite"></u-icon>
				</view>
				<!-- <u-icon name="star" color="#999999" size="22"></u-icon> -->
			</view>
			<view class="margin_top2 xiaohei ershiba nofonweight">{{item.content}}</view>
			<view class="flexleft flex_wrap">
				<view class="sanshis flexcenter margin_top2" v-for="(ite,inde) in item.images_text" :key="inde">
					<view class="jiaolt">
						<image :src="ite" mode="" @click="lbtpriview(inde,item.images_text)"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				type:1,//1商品评价,2课程评价，3场地评价
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.type = options.type
			this.init()
		},
		methods: {
			lbtpriview(index,arr) {
							var i = arr; //获取当前页面的轮播图数据
							//uniapp预览轮播图
							uni.previewImage({
								current: index, //预览图片的下标
								urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
							})
						},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					goods_id:this.listid
				}
				let url = '/api/scoregoods/goodsCommentList'
				if(this.type==2){
					url = '/api/kccl/kcCommentList'
					delete data.goods_id
					this.$set(data,"kc_id",this.listid)
				}
				if(this.type==3){
					url = '/api/cgcl/cgCommentList'
					delete data.goods_id
					this.$set(data,"cg_id",this.listid)
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>